package com.zb.select.controller;

import com.zb.entity.SelectVo;
import com.zb.result.PageUtil;
import com.zb.result.Result;
import com.zb.service.*;
import com.zb.utils.TokenUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @Author WEN
 * @Date 2023/8/14 0014
 **/
@Api(tags = "系统类下拉接口")
@RestController
@RequestMapping("/system/select")
public class SystemSelectController {
    @Resource
    private ZjEmpService empService;
    @Resource
    private ZjOrganizeService organizeService;
    @Resource
    private ZjRoleService roleService;
    @Resource
    private ZjSmsTemplateService smsTemplateService;

    @ApiOperation("企业人员下拉数据列表")
    @PostMapping("/empPageSelecct")
    public Result empPageSelecct(HttpServletRequest request, @RequestBody SelectVo selectVo) {
        Long custAccId = TokenUtil.getcustAccIdByToken(request);
        return Result.success("获取企业人员下拉数据成功").data(empService.pageEmpSelecct(custAccId, selectVo));
    }

    @ApiOperation("企业组织下拉数据列表")
    @PostMapping("/organizePageSelecct")
    public Result organizePageSelecct(HttpServletRequest request, @RequestBody SelectVo selectVo) {
        Long custAccId = TokenUtil.getcustAccIdByToken(request);
        return Result.success("获取企业组织下拉数据成功").data(organizeService.pageSelecct(custAccId, selectVo));
    }

    @ApiOperation("企业角色下拉数据列表")
    @PostMapping("/rolePageSelect")
    public Result rolePageSelect(HttpServletRequest request, @RequestBody SelectVo selectVo) {
        Long custAccId = TokenUtil.getcustAccIdByToken(request);
        return Result.success("获取企业角色下拉数据成功").data(roleService.pageSelecct(custAccId, selectVo));
    }

    @ApiOperation("根据短信模板ID获取短信接收角色类型下拉数据")
    @GetMapping("/getRoleType/{id}")
    public Result getRoleType(@PathVariable @ApiParam(value = "短信模板ID") Long id) {
        return Result.success("获取短信接收角色类型下拉数据成功").data(PageUtil.rows(smsTemplateService.getAdmRoleTypeSelect(id)));
    }

}
